﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace vmreg
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hyper-V Virtual Machine Attach Tool - Tool by Jerome Laban (http://vmmove.codeplex.com or http://www.jaylee.org)");

            if (args.Length < 2)
            {
                Console.WriteLine("To attach a VM\n\tVMMove a [vm base path]( [host machine])");
                Console.WriteLine("To detach a VM\n\tVMMove d [vm name]( [host machine])");
                return;
            }

            var method = args[0];
            var vmPath = args[1];

            var hostMachine = args.Length > 2 ? args[2]:"";


            try
            {
                HyperVMover.HyperVUtils.LogMessage += m => Console.WriteLine(m);

                switch (method)
                {
                    case "a":
                        HyperVMover.HyperVUtils.AttachVM(null, vmPath, hostMachine);
                        break;
                    case "d":
                        HyperVMover.HyperVUtils.DetachVM(vmPath, hostMachine);
                        break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
